<?php

require_once("functions.php");

?>

<html>
	<head>
		   <title>solution</title>
	</head>
	<body>
<?php

	$query = "SELECT * FROM sap_Items ";

	$query .= processQueryParameters("sap.sap_Items", false, "N");
	$query .= processSortParameters();

	$mysqlCountQuery = mysql_query($query);
	$recordCount = mysql_num_rows($mysqlCountQuery);

	$startRowStr = isset($_REQUEST['startRow']) ? $_REQUEST['startRow'] : null;

                if ($startRowStr == "") {
                        $startIndex = -1;
                } else {
                        $startIndex = (int)$startRowStr - 1;
                }

                $numberOfRowsStr = isset($_REQUEST['numberOfRows']) ? $_REQUEST['numberOfRows'] : null;

                if ($numberOfRowsStr == "")
                        $numberOfRows = 1000000000;
                else
                        $numberOfRows = (int)$numberOfRowsStr;

		$limitStr = "";

                if ($startIndex > -1)
                        $limitStr = " LIMIT ".$startIndex.",".$numberOfRows;

	if ($startIndex = 0)
		$startIndex = 1;


	$queryWithPagination = $query." ".$limitStr;

error_log("query = ".$queryWithPagination);


	$connectDBPtr = mysql_connect("localhost:3306","sap","sap213");
	if (!$connectDBPtr) { 
		die('Could not connect:' . mysql_error());
	}
	mysql_query("SET NAMES 'utf8'");
	$db = mysql_select_db("sap",$connectDBPtr);
	if (!$db) { 
		die('Could not connect:' . mysql_error());
	}
	$mysqlCountQuery = mysql_query($query);
	$recordCount = mysql_num_rows($mysqlCountQuery);
	$variable1 = mysql_query($queryWithPagination);
	#$rowCount = mysql_query("SELECT count(*) record_count FROM sap_Items");
	#$recordCount = 0;
	#while ($row = mysql_fetch_array($rowCount)) {
	#	$recordCount = $row["record_count"];
	#}
		 if(mysql_num_rows($variable1)<1) {
			 die("Table Empty");
		}
?>
		<table data-bitzer-data="TRUE"
		       data-bitzer-title="Solution"
		       data-bitzer-desc="solution"
		       data-bitzer-component="solution"
		       class="solution" width="100%" border="1"
		data-bitzer-start-index="<?php echo $startIndex ?>" data-bitzer-number-of-rows="<?php echo $numberOfRows ?>" data-bitzer-record-count="<? echo $recordCount ?>"	>
			      <tr>
				      <th data-bitzer-field="id" data-bitzer-key-order="1"> id </th>
				      <th data-bitzer-field="Dt"> Dt </th>
				      <th data-bitzer-field="CreationDate"> CreationDate </th>
				      <th data-bitzer-field="Partner"> Partner </th>
				      <th data-bitzer-field="Solution"> Solution </th>
				      <th data-bitzer-field="SolutionType"> SolutionType </th>
				      <th data-bitzer-field="Source"> Source </th>
				      <th data-bitzer-field="InquiryType"> InquiryType </th>
				      <th data-bitzer-field="Salutation"> Salutation </th>
				      <th data-bitzer-field="Title"> Title </th>
				      <th data-bitzer-field="FirstName"> FirstName </th>
				      <th data-bitzer-field="Name"> Name </th>
				      <th data-bitzer-field="JobRole"> JobRole </th>
				      <th data-bitzer-field="Company"> Company </th>
				      <th data-bitzer-field="Industry"> Industry </th>
				      <th data-bitzer-field="Address1"> Address1 </th>
				      <th data-bitzer-field="Address2"> Address2 </th>
				      <th data-bitzer-field="City"> City </th>
				      <th data-bitzer-field="Zip"> Zip </th>
				      <th data-bitzer-field="Country"> Country </th>
				      <th data-bitzer-field="Region"> Region </th>
				      <th data-bitzer-field="Phone"> Phone </th>
				      <th data-bitzer-field="FAX"> FAX </th>
				      <th data-bitzer-field="Email"> Email </th>
				      <th data-bitzer-field="ContactType"> ContactType </th>
				      <th data-bitzer-field="RelationshiptoSAP"> RelationshiptoSAP </th>
				      <th data-bitzer-field="AdditionalText"> AdditionalText </th>
				      <th data-bitzer-field="Status"> Status </th>
				      <th data-bitzer-field="ECOHUBID"> ECOHUBID </th>
				      <th data-bitzer-field="CampaignID"> CampaignID </th>
				      <th data-bitzer-field="LeadStatus"> LeadStatus </th>
				      <th data-bitzer-field="Activities"> Activities </th>
				      <th data-bitzer-field="Leads"> Leads </th>
				      <th data-bitzer-field="Opportunities"> Opportunities </th>
				      <th data-bitzer-field="ProposedDeals"> ProposedDeals </th>
				      <th data-bitzer-field="ClosedDeals"> ClosedDeals </th>
				      <th data-bitzer-field="Contacts"> Contacts </th>
				      <th data-bitzer-field="DGID"> DGID </th>
			      </tr>
<?php
while($row = mysql_fetch_array($variable1)) {
	$id = $row["id"];
	$Dt = $row["Dt"];
	$CreationDate = $row["CreationDate"];
	$Partner = $row["Partner"];
	$Solution = $row["Solution"];
	$SolutionType = $row["SolutionType"];
	$Source = $row["Source"];
	$InquiryType = $row["InquiryType"];
	$Salutation = $row["Salutation"];
	$Title = $row["Title"];
	$FirstName = $row["FirstName"];
	$Name = $row["Name"];
	$JobRole = $row["JobRole"];
	$Company = $row["Company"];
	$Industry = $row["Industry"];
	$Address1 = $row["Address1"];
	$Address2 = $row["Address2"];
	$City = $row["City"];
	$Zip = $row["Zip"];
	$Country = $row["Country"];
	$Region = $row["Region"];
	$Phone = $row["Phone"];
	$FAX = $row["FAX"];
	$Email = $row["Email"];
	$ContactType = $row["ContactType"];
	$RelationshiptoSAP = $row["RelationshiptoSAP"];
	$AdditionalText = $row["AdditionalText"];
	$Status = $row["Status"];
	$ECOHUBID = $row["ECOHUBID"];
	$CampaignID = $row["CampaignID"];
	$LeadStatus = $row["LeadStatus"];
	$Activities = $row["Activities"];
	$Leads = $row["Leads"];
	$Opportunities = $row["Opportunities"];
	$ProposedDeals = $row["ProposedDeals"];
	$ClosedDeals = $row["ClosedDeals"];
	$Contacts = $row["Contacts"];
	$DGID = $row["DGID"];
	echo " <tr data-bitzer-pk-name=\"id\" data-bitzer-pk-value=\"",strip_tags($id),"\">";
	echo "<td>".strip_tags($id)."</td>";
	echo "<td>".strip_tags($Dt)."</td>";
	echo "<td>" . strip_tags($CreationDate)."</td>";
	echo "<td>" . strip_tags($Partner)."</td>";
	echo "<td>" . strip_tags($Solution)."</td>";
	echo "<td>" . strip_tags($SolutionType)."</td>";
	echo "<td>" . strip_tags($Source)."</td>";
	echo "<td>" . strip_tags($InquiryType)."</td>";
	echo "<td>" . strip_tags($Salutation)."</td>";
	echo "<td>" . strip_tags($Title)."</td>";
	echo "<td>" . strip_tags($FirstName)."</td>";
	echo "<td>" . strip_tags($Name)."</td>";
	echo "<td>" . strip_tags($JobRole)."</td>";
	echo "<td>" . strip_tags($Company)."</td>";
	echo "<td>" . strip_tags($Industry)."</td>";
	echo "<td>" . strip_tags($Address1)."</td>";
	echo "<td>" . strip_tags($Address2)."</td>";
	echo "<td>" . strip_tags($City)."</td>";
	echo "<td>" . strip_tags($Zip)."</td>";
	echo "<td>" . strip_tags($Country)."</td>";
	echo "<td>" . strip_tags($Region)."</td>";
	echo "<td>" . strip_tags($Phone)."</td>";
	echo "<td>" . strip_tags($FAX)."</td>";
	echo "<td>" . strip_tags($Email)."</td>";
	echo "<td>" . strip_tags($ContactType)."</td>";
	echo "<td>" . strip_tags($RelationshiptoSAP)."</td>";
	echo "<td>" . strip_tags($AdditionalText)."</td>";
	echo "<td>" . strip_tags($Status)."</td>";
	echo "<td>" . strip_tags($ECOHUBID)."</td>";
	echo "<td>" . strip_tags($CampaignID)."</td>";
	echo "<td>" . strip_tags($LeadStatus)."</td>";
	echo "<td>" . strip_tags($Activities)."</td>";
	echo "<td>" . strip_tags($Leads)."</td>";
	echo "<td>" . strip_tags($Opportunities)."</td>";
	echo "<td>" . strip_tags($ProposedDeals)."</td>";
	echo "<td>" . strip_tags($ClosedDeals)."</td>";
	echo "<td>" . strip_tags($Contacts)."</td>";
	echo "<td>" . strip_tags($DGID)."</td>";
	echo "</tr>";
	}
	mysql_close($connectDBPtr);
?>
		</table>
	</body>
</html>
